package com.ltkj.baseplatform.service.impl;

import java.util.List;

import com.ltkj.common.core.constant.CacheConstants;
import com.ltkj.common.core.utils.DateUtils;
import com.ltkj.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ltkj.baseplatform.mapper.SerTravelTypeMapper;
import com.ltkj.baseplatform.domain.SerTravelType;
import com.ltkj.baseplatform.service.ISerTravelTypeService;

/**
 * 游记分类Service业务层处理
 * 
 * @author chenzeen
 * @date 2023-09-02
 */
@Service
public class SerTravelTypeServiceImpl implements ISerTravelTypeService 
{
    @Autowired
    private SerTravelTypeMapper serTravelTypeMapper;

    @Autowired
    private RedisService redisService;

    /**
     * 查询游记分类
     * 
     * @param typeId 游记分类主键
     * @return 游记分类
     */
    @Override
    public SerTravelType selectSerTravelTypeByTypeId(Long typeId)
    {
        return serTravelTypeMapper.selectSerTravelTypeByTypeId(typeId);
    }

    /**
     * 查询游记分类列表
     * 
     * @param serTravelType 游记分类
     * @return 游记分类
     */
    @Override
    public List<SerTravelType> selectSerTravelTypeList(SerTravelType serTravelType)
    {
        return serTravelTypeMapper.selectSerTravelTypeList(serTravelType);
    }

    /**
     * 新增游记分类
     * 
     * @param serTravelType 游记分类
     * @return 结果
     */
    @Override
    public int insertSerTravelType(SerTravelType serTravelType)
    {
        serTravelType.setCreateTime(DateUtils.getNowDate());
        int i = serTravelTypeMapper.insertSerTravelType(serTravelType);
        if(i > 0){
            //首页综合推荐分类缓存
            redisService.deleteObject(CacheConstants.HOME_TAB_TYPE_KEY);
        }
        return i;
    }

    /**
     * 修改游记分类
     * 
     * @param serTravelType 游记分类
     * @return 结果
     */
    @Override
    public int updateSerTravelType(SerTravelType serTravelType)
    {
        serTravelType.setUpdateTime(DateUtils.getNowDate());
        int i = serTravelTypeMapper.updateSerTravelType(serTravelType);
        if(i > 0){
            //首页综合推荐分类缓存
            redisService.deleteObject(CacheConstants.HOME_TAB_TYPE_KEY);
        }
        return i;
    }

    /**
     * 批量删除游记分类
     * 
     * @param typeIds 需要删除的游记分类主键
     * @return 结果
     */
    @Override
    public int deleteSerTravelTypeByTypeIds(Long[] typeIds)
    {
        int i = serTravelTypeMapper.deleteSerTravelTypeByTypeIds(typeIds);
        if(i > 0){
            //首页综合推荐分类缓存
            redisService.deleteObject(CacheConstants.HOME_TAB_TYPE_KEY);
        }
        return i;
    }

    /**
     * 删除游记分类信息
     * 
     * @param typeId 游记分类主键
     * @return 结果
     */
    @Override
    public int deleteSerTravelTypeByTypeId(Long typeId)
    {
        return serTravelTypeMapper.deleteSerTravelTypeByTypeId(typeId);
    }
}
